import axios from "axios";
import store from "../store.js";
const $require = axios.create({
  timeout: 5000,
  baseURL:'https://www.easy-mock.com/mock/5d70d472fa1dc7414ed9456e'
});

// 请求拦截
$require.interceptors.request.use(
  config => {
    let token = store.state.token;
    if (token) {
      config.headers.Authorize = token;
    }
    return config;
  },
  error => {
    return Promise.reject(error);
  }
);

// 响应拦截

$require.interceptors.response.use(
  response => {
    return response;
  },
  error => {
    return Promise.reject(error);
  }
);

export default $require;